/**
 * 
 */
package org.zgstudio.ddlchecker;

import java.util.Date;

/**
 * @author zhguo
 * 
 */
public class LinkCheckResult {
    private Link       linkChecked;

    /*
     * 0: succeed 1: timeout 2: connection refused
     */
    private ResultCode result;

    private Date       checkTime;
    private Date       completionTime;

    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("link:" + linkChecked.getUrl()).append("\n").append(
                "    Check time:" + checkTime).append(
                "\n    Completion time:" + completionTime).append(
                "\n    result:" + result.getDescription());
        return sb.toString();
    }
    
    public void setResultCode(ResultCode result) {
        this.result = result;
    }

    public ResultCode getResult() {
        return result;
    }

    public void setCheckTime(Date checkTime) {
        this.checkTime = checkTime;
    }

    public Date getCheckTime() {
        return checkTime;
    }

    public void setLinkChecked(Link linkChecked) {
        this.linkChecked = linkChecked;
    }

    public Link getLinkChecked() {
        return linkChecked;
    }

    public void setCompletionTime(Date completionTime) {
        this.completionTime = completionTime;
    }

    public Date getCompletionTime() {
        return completionTime;
    }
}

enum ResultCode {
    SUCCEED("succeeded"),
    TIMEOUT("timeout"),
    FAILED("failed"),
    UNRECOG_PROTO("unrecognized protocol"),
    REDIRECT("redirect"),
    DELETE_FSILED("deletion failed"),
    DELETED("deleted");
    
    private String description;

    ResultCode(String desp) {
        this.description = desp;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }

    public String getDescription() {
        return description;
    }
}